export default <T extends object>(target: new () => T) => {
    let instance: T;

    const proxy = new Proxy(target, {
        construct(target, args) {
            if (!instance) instance = Reflect.construct(target, args);
            return instance;
        },
    });

    proxy.prototype.constructor = proxy;

    return proxy;
};
